import { Component } from '@angular/core';
import { Router } from '@angular/router';

@Component({
  selector: 'body',
  template: '<router-outlet></router-outlet>',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {

  constructor(private router: Router) {}

  ngOnInit() {
    const nowTime: any = new Date().getTime().toString().substr(0, 10);
    if (!localStorage.token || !localStorage.tokenTime || nowTime - localStorage.tokenTime > 7200) {
      console.log(localStorage.token)
      localStorage.token = ''
      localStorage.tokenTime = 0
      this.router.navigateByUrl('/login');
    }
  }
}